cmake_minimum_required(VERSION 2.8)

file(GLOB Toolchains ${CMAKE_ROOT}/Modules/SBE/toolchains/*.cmake)

set(exampleName "")

foreach(tc ${Toolchains})
    get_filename_component(name "${tc}" NAME)
    string(REPLACE ".cmake" "" name "${name}")
    set(exampleName ${name})
    
    message("")
    message("${name}")
   
    set(printLine yes)
    file(STRINGS ${tc} description)
    foreach(line ${description})
        if("${line}" MATCHES "^#.*")
            string(REGEX REPLACE "^#(.*)" "\\1" line "${line}") 
            if(printLine)
                message("    ${line}")
            endif()
        else()
            set(printLine no)
        endif()
    endforeach()
    
endforeach()

if(NOT "" STREQUAL "${exampleName}")
    message("")
    message("The name of toolchain is always in format board-system-extension-architecture-compiler-compiler_version")
    message("")
    message("Use the toolchain name during cmake invocation.")
    message("E.g. cmake -DCMAKE_TOOLCHAIN_FILE=SBE/toolchains/${exampleName}")
endif()           
